package com.itheima.dao;

import com.itheima.bean.Student;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

public class AddStudent {
    public void addStudent(String username,String age,String score) throws IOException {
        Student stu = new Student();
        stu.setUsername(username);
        stu.setAge(Integer.parseInt(age));
        stu.setScore(Integer.parseInt(score));

        //将学生对象的数据保留到E盘下的stu.txt下
        // resp.setContentType("text/html;charset=UTF-8 ");
        BufferedWriter bw = new BufferedWriter(new FileWriter("e:\\stu.txt", true));
        bw.write(stu.getUsername() + "," + stu.getAge() + "," + stu.getScore());
        bw.newLine();
        bw.close();
    }
}
